package constraint;

import java.util.List;

import choco.Constraint;
import expression.MIntVar;

public class MNot extends MConstraint {
	private MConstraint constraint;

	public MNot(MConstraint c) {
		super(c.getCore());
		constraint = c;
	}

	public Constraint constraint() {
		return getCore().getProblem().not(constraint.eval().constraint());
	}

	public MConstraint eval() {
		MConstraint c = constraint.eval();
		if (c instanceof MTrue)
			return new MFalse(getCore());
		else if (c instanceof MFalse)
			return new MTrue(getCore());
		else
			return c;
	}

	public List<MIntVar> getVariables() {
		return constraint.getVariables();
	}

	public String toText() {
		return "(not " + constraint.toText() + ")";
	}

}
